package com.qf.listener;

import com.event.util.EventHandler;
import com.event.util.EventType;
import com.qf.entity.Msg;
import com.qf.util.ChannelMap;
import io.netty.channel.Channel;
import org.springframework.stereotype.Component;

@Component
@EventType("tixing")
public class TixingListener implements EventHandler<Msg> {

    @Override
    public void msgHandler(Msg msg) {
        System.out.println("消息中心接收到需要推送的消息：" + msg);
        Channel channel = ChannelMap.getChannel(msg.getTo());
        if (channel != null) {
            channel.writeAndFlush(msg);
        } else {
            System.out.println("客户端未在线！");
        }
    }
}
